import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import 'font-awesome/css/font-awesome.css';
import {getRequest} from "./utils/api";
import {postRequest} from "./utils/api";
import {putRequest} from "./utils/api";
import {deleteRequest} from "./utils/api";
import ViewUI from 'view-design';
import 'view-design/dist/styles/iview.css';
import '@/assets/css/common.less';
import '@/assets/css/variable.less';
import '@/assets/css/theme/459f75/index.css';
import { get } from 'jquery';
import {initMenu} from "@/utils/menus";
Vue.prototype.getRequest = getRequest;
Vue.prototype.postRequest=postRequest
Vue.prototype.putRequest=putRequest
Vue.prototype.deleteRequest=deleteRequest
Vue.use(ElementUI,{size:'small'});
Vue.use(ViewUI );
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

// router.beforeEach((to,from,next)=>{
//   if (window.sessionStorage.getItem('tokenStr')) {
//     // 已经登录
//     initMenu(router,store);
//     //判断用户是否存在
//     if(!window.sessionStorage.getItem('user')){
//       return getRequest('/admin/info').then(resp=>{
//         if(resp){
//           //存入用户信息
//           window.sessionStorage.setItem('user',JSON.stringify(resp));
//           store.commit('init_admin',resp);
//           next();
//         }
//       })
//     }
//     next();
//   }else {
//     console.log(123);
//     //未登录  这里是 logout 之后 未登录，去 / 要放行
//     if (to.path == '/') {
//       next();
//     }else {
//       next('/?redirect='+to.path);
//     }
//   }
// })